package com.oauth.resource.controller;

import com.oauth.common.api.BaseResponse;
import com.oauth.resource.feign.OauthFeign;
import com.oauth.resource.vo.UserGetDetailVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/feign/test")
public class FeignTestController {

    @Autowired
    private OauthFeign oauthFeign;

    @GetMapping("xWwwFormUrlencoded")
    public BaseResponse<Map<String, Object>> xWwwFormUrlencoded(){
        BaseResponse<Map<String, Object>> baseResponse = oauthFeign.xWwwFormUrlencoded(1,"小明");
        return baseResponse;
    }

    @GetMapping("xWwwFormUrlencoded2")
    public BaseResponse<String> xWwwFormUrlencoded2(){
        return oauthFeign.xWwwFormUrlencoded2("小明");
    }

    @GetMapping("json1")
    public BaseResponse json1(){
        BaseResponse<UserGetDetailVO> response = oauthFeign.json1(new UserGetDetailVO(1, "小明"));
        return response;
    }

    @GetMapping("json2")
    public BaseResponse<String> test3(){
        BaseResponse<String> baseResponse = oauthFeign.json2("小明");
        return baseResponse;
    }

    @GetMapping("text1")
    public BaseResponse<String> text1(){
        BaseResponse<String> baseResponse = oauthFeign.text1("小明");
        return baseResponse;
    }

    @GetMapping("form1")
    public BaseResponse<Map<String, Object>> form1(){
        BaseResponse<Map<String, Object>> response = oauthFeign.form1(1, "小明");
        return response;
    }

    @GetMapping("form2")
    public BaseResponse<Map<String, Object>> form2(){
        BaseResponse<Map<String, Object>> response = oauthFeign.form2(1, "小明");
        return response;
    }

    @GetMapping("query")
    public BaseResponse<Map<String, Object>> query(){
        BaseResponse<Map<String, Object>> response = oauthFeign.query(new UserGetDetailVO(1,"小明"));
        return response;
    }
}
